import Global from "../../../Global"
import cjs=createjs
//import createjs from "../../../../createjs"
export default class NumberWord extends cjs.Container{
    private digits:cjs.MovieClip[]=[]
    constructor(){
        super()
    }
    setValue(value:number):void{
        const lib=Global.getLibrary()
        const str=value.toString()
        const len=str.length
        let i=0;
        for(i=0;i<len;i++){
            let mc
            if(i<this.digits.length){
                mc=this.digits[i]
            }else{
                mc=new lib.Digit()
                this.digits.push(mc)
            }
            mc.gotoAndStop(parseInt(str.charAt(i)))
            mc.setTransform(28*i,0)
            this.addChild(mc)
        }
        if(i<this.digits.length){
            for(;i<len;i++){
                const mc=this.digits[i]
                this.removeChild(mc)
            }
        }
    }
    getBounds(): cjs.Rectangle {
        return super.getBounds()||new cjs.Rectangle(0,0,0,0)
    }
}